/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ListadoIngrediente.java
 *
 * Created on 08/04/2011, 09:20:54 AM
 */

package vistas;

import controladores.ControladorListadoIngrediente;
import java.util.Vector;
import javax.swing.JButton;

import modelos.ModeloDB;
import modelos.ModeloIngrediente;
import modelos.ModeloTabla;

/**
 *
 * @author usuario
 */
public class ListadoIngrediente extends javax.swing.JFrame {
    private Vector<JButton> botones;
    private ControladorListadoIngrediente control;
    private ModeloTabla modeloTabla;
    private Vector<String> identificadores, fila;

    /** Creates new form ListadoIngrediente */
    public ListadoIngrediente() {
        initComponents();
        modeloTabla= new ModeloTabla();
        jTable2.setModel(modeloTabla);

        identificadores= new Vector<String>();

        identificadores.add("Ingrdiente");
        identificadores.add("Cantidad Disponible");
        modeloTabla.setColumnIdentifiers(identificadores);
        botones = new Vector<JButton>();
        botones.add(btnSalir);
        botones.add(btnConsultar);
        btnConsultar.setActionCommand("Consultar");
        btnSalir.setActionCommand("Salir");
        control = new  ControladorListadoIngrediente(this);
        for (JButton boton : botones) {
            boton.addActionListener(control);
        }
    }

    public void agregar(ModeloDB m){
        fila= new Vector<String>();
        fila.add( ((ModeloIngrediente)m).getDescripcion());
        fila.add(""+((ModeloIngrediente)m).getStock());

                modeloTabla.addRow(fila);
            
        }

    public ModeloTabla getModeloTabla() {
        return modeloTabla;
    }



    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane2 = new javax.swing.JScrollPane();
        jTable2 = new javax.swing.JTable();
        btnConsultar = new javax.swing.JButton();
        btnSalir = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Listado de Ingredientes Dispobibles");
        getContentPane().setLayout(null);

        jTable2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane2.setViewportView(jTable2);

        getContentPane().add(jScrollPane2);
        jScrollPane2.setBounds(20, 30, 452, 402);

        btnConsultar.setFont(new java.awt.Font("Arial", 1, 15));
        btnConsultar.setText("Consultar");
        getContentPane().add(btnConsultar);
        btnConsultar.setBounds(50, 450, 120, 30);

        btnSalir.setFont(new java.awt.Font("Arial", 1, 15));
        btnSalir.setText("Salir");
        getContentPane().add(btnSalir);
        btnSalir.setBounds(310, 450, 120, 30);

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-500)/2, (screenSize.height-522)/2, 500, 522);
    }// </editor-fold>//GEN-END:initComponents

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new ListadoIngrediente().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnConsultar;
    private javax.swing.JButton btnSalir;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable jTable2;
    // End of variables declaration//GEN-END:variables

}
